package com.archie.xunji.guanzhu.entitys;

import android.util.Log;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;

/**
 * Created by xqx on 2015/11/10.
 */

/*
  {
                "user_type": 2,
                "placeid": 3000,
                "attitudecount": 133,
                "labels": "生活",
                "createdate": 1446801883000,
                "userinfoid": 4648,
                "playcount": 258,
                "audiolength": "230",
                "placename": "武汉体育学院",
                "headurl": "user/person/i8e031844-819e-4be3-a215-72bdc9582136.jpg",
                "storyid": 6351,
                "audiourl": "cms/audio/18db5e0d-0973-4877-a132-fe5bae313d23.mp3",
                "hotnum": 0,
                "username": "循迹君",
                "title": "骗子太少不够用",
                "commentcount": 1,
                "favouritecount": 1,
                "placedesc": "",
                "description": "11.9地点新闻\r\n广西小伙入传销窝点骗取34万后脱身\r\n北京通州制作假肉包子\r\n小偷武体行窃被围堵主动报警求助\r\n",
                "longitude": "114.37848800",
                "latitude": "30.52030600",
                "sharecount": 0,
                "imageurl": "cms/story/64b44de3-1900-4d4e-ba67-950870dae1aa.jpg"
            },
 */
public class Attention implements Serializable{
    private int user_type;
    private int placeid;
    private int attitudecount;
    private String labels;
    private long createdate;
    private int userinfoid;
    private int playcount;
    private String audiolength;
    private String placename;
    private String headurl;
    private int storyid;
    private String audiourl;
    private int hotnum;
    private String username;
    private String title;
    private int commentcount;
    private int favouritecount;
    private String placedesc;
    private String description;
    private String longitude;
    private String latitude;
    private int sharecount;
    private String imageurl;
    private String surplusTime;

    private boolean isAttituded;  //是否点赞
    private boolean isFavourited; //是否收藏
    private boolean isPlaying;    //是否正在播放
    public static List<Attention> getAttentionData(String json){
        List<Attention> list = null;
        if (json != null) {
            Log.i("attention",json);

            try {
                list = new ArrayList<>();
                JSONObject obj = new JSONObject(json);
                JSONObject result = obj.getJSONObject("result");
                JSONArray data = result.getJSONArray("data");
                Attention attention = null;
                for (int i = 0; i < 30; i++) {
                    JSONObject at = data.getJSONObject(i);
                    attention = new Attention();
                    int xplaceid = at.getInt("placeid");
                    attention.setPlaceid(xplaceid);
                    int xattitudecount = at.getInt("attitudecount");
                    attention.setAttitudecount(xattitudecount);
                    String xlabels = at.getString("labels");
                    attention.setLabels(xlabels);
                    long xcreatedata = at.getLong("createdate");
                    attention.setCreatedate(xcreatedata);
                    int xuserinfoid = at.getInt("userinfoid");
                    attention.setUserinfoid(xuserinfoid);
                    int xplaycount = at.getInt("playcount");
                    attention.setPlaycount(xplaycount);
                    String xaudiolength = at.getString("audiolength");
                    attention.setAudiolength(xaudiolength);
                    String xplacename = at.getString("placename");
                    attention.setPlacename(xplacename);

                    String xheadurl = at.getString("headurl");
                    attention.setHeadurl(xheadurl);

                    int xstoryid = at.getInt("storyid");
                    attention.setStoryid(xstoryid);

                    String xaudiourl = at.getString("audiourl");
                    attention.setAudiourl(xaudiourl);

                    int xhotnum = at.getInt("hotnum");
                    attention.setHotnum(xhotnum);

                    String xusername = at.getString("username");
                    attention.setUsername(xusername);

                    String xtitle = at.getString("title");
                    attention.setTitle(xtitle);

                    int xcommentcount = at.getInt("commentcount");
                    attention.setCommentcount(xcommentcount);

                    int xfavouritecount = at.getInt("favouritecount");
                    attention.setCommentcount(xfavouritecount);

                    String xdescription = at.getString("description");
                    attention.setDescription(xdescription);

                    String xlongitude = at.getString("longitude");
                    attention.setLongitude(xlongitude);

                    String xlatitude = at.getString("latitude");
                    attention.setLatitude(xlatitude);

                    int xsharecount = at.getInt("sharecount");
                    attention.setSharecount(xsharecount);
                    String ximageurl = at.getString("imageurl");
                    attention.setImageurl(ximageurl);

                    attention.setSurplusTime(xaudiolength);
                    attention.setIsAttituded(false);
                    attention.setIsFavourited(false);
                    attention.setIsPlaying(false);
                    list.add(attention);
                }
            } catch (JSONException e) {
                e.printStackTrace();
            }

        }

        return list;
    }

    public void setSurplusTime(String surplusTime) {
        this.surplusTime = surplusTime;
    }

    public String getSurplusTime() {
        return surplusTime;
    }

    public void setIsPlaying(boolean isPlaying) {
        this.isPlaying = isPlaying;
    }

    public boolean isPlaying() {
        return isPlaying;
    }

    public void setIsAttituded(boolean isAttituded) {
        this.isAttituded = isAttituded;
    }

    public void setIsFavourited(boolean isFavourited) {
        this.isFavourited = isFavourited;
    }

    public boolean isAttituded() {
        return isAttituded;
    }

    public boolean isFavourited() {
        return isFavourited;
    }

    public void setUser_type(int user_type) {
        this.user_type = user_type;
    }

    public void setPlaceid(int placeid) {
        this.placeid = placeid;
    }

    public void setAttitudecount(int attitudecount) {
        this.attitudecount = attitudecount;
    }

    public void setLabels(String labels) {
        this.labels = labels;
    }

    public void setCreatedate(long createdate) {
        this.createdate = createdate;
    }

    public void setUserinfoid(int userinfoid) {
        this.userinfoid = userinfoid;
    }

    public void setPlaycount(int playcount) {
        this.playcount = playcount;
    }

    public void setAudiolength(String audiolength) {
        this.audiolength = audiolength;
    }

    public void setPlacename(String placename) {
        this.placename = placename;
    }

    public void setHeadurl(String headurl) {
        this.headurl = headurl;
    }

    public void setStoryid(int storyid) {
        this.storyid = storyid;
    }

    public void setAudiourl(String audiourl) {
        this.audiourl = audiourl;
    }

    public void setHotnum(int hotnum) {
        this.hotnum = hotnum;
    }

    public void setUsername(String username) {
        this.username = username;
    }

    public void setTitle(String title) {
        this.title = title;
    }

    public void setCommentcount(int commentcount) {
        this.commentcount = commentcount;
    }

    public void setFavouritecount(int favouritecount) {
        this.favouritecount = favouritecount;
    }

    public void setPlacedesc(String placedesc) {
        this.placedesc = placedesc;
    }

    public void setDescription(String description) {
        this.description = description;
    }

    public void setLongitude(String longitude) {
        this.longitude = longitude;
    }

    public void setLatitude(String latitude) {
        this.latitude = latitude;
    }

    public void setSharecount(int sharecount) {
        this.sharecount = sharecount;
    }

    public void setImageurl(String imageurl) {
        this.imageurl = imageurl;
    }

    public int getUser_type() {
        return user_type;
    }

    public int getPlaceid() {
        return placeid;
    }

    public int getAttitudecount() {
        return attitudecount;
    }

    public String getLabels() {
        return labels;
    }

    public long getCreatedate() {
        return createdate;
    }

    public int getUserinfoid() {
        return userinfoid;
    }

    public int getPlaycount() {
        return playcount;
    }

    public String getAudiolength() {
        return audiolength;
    }

    public String getPlacename() {
        return placename;
    }

    public String getHeadurl() {
        return headurl;
    }

    public int getStoryid() {
        return storyid;
    }

    public String getAudiourl() {
        return audiourl;
    }

    public int getHotnum() {
        return hotnum;
    }

    public String getUsername() {
        return username;
    }

    public String getTitle() {
        return title;
    }

    public int getCommentcount() {
        return commentcount;
    }

    public int getFavouritecount() {
        return favouritecount;
    }

    public String getPlacedesc() {
        return placedesc;
    }

    public String getDescription() {
        return description;
    }

    public String getLongitude() {
        return longitude;
    }

    public String getLatitude() {
        return latitude;
    }

    public int getSharecount() {
        return sharecount;
    }

    public String getImageurl() {
        return imageurl;
    }

    @Override
    public String toString() {
        return "Attention{" +
                "user_type=" + user_type +
                ", placeid=" + placeid +
                ", attitudecount=" + attitudecount +
                ", labels='" + labels + '\'' +
                ", createdate=" + createdate +
                ", userinfoid=" + userinfoid +
                ", playcount=" + playcount +
                ", audiolength='" + audiolength + '\'' +
                ", placename='" + placename + '\'' +
                ", headurl='" + headurl + '\'' +
                ", storyid=" + storyid +
                ", audiourl='" + audiourl + '\'' +
                ", hotnum=" + hotnum +
                ", username='" + username + '\'' +
                ", title='" + title + '\'' +
                ", commentcount=" + commentcount +
                ", favouritecount=" + favouritecount +
                ", placedesc='" + placedesc + '\'' +
                ", description='" + description + '\'' +
                ", longitude='" + longitude + '\'' +
                ", latitude='" + latitude + '\'' +
                ", sharecount=" + sharecount +
                ", imageurl='" + imageurl + '\'' +
                '}';
    }


}
